import * as types from '@src/model/actionType';
import { combineReducers } from 'redux';

// 交易统计曲线
const chainListState = {
  TotalCount: 0,
  GroupList: [
    {
      Id: 1, // 链逻辑ID
      ChainID: 'chain1', // 链ID
      Consensus: 'PBFT', // 共识算法
      Timestamp: 1606669261, // 时间戳
    },
  ],
};

function chainList(state = chainListState, action) {
  switch (action.type) {
    case types.chainList:
      return { ...state, ...action.payload };
    default:
      return state;
  }
}

// 区块列表
const blockListState = {
  TotalCount: 2,
  GroupList: [{ Id: 1, BlockHash: 'asasd12', TxCount: 4, ProposalNodeId: 'dasd', Timestamp: 1606669261 }],
};
function blockList(state = blockListState, action) {
  switch (action.type) {
    case types.blockList:
      return { ...state, ...action.payload };
    default:
      return state;
  }
}

const reducer = combineReducers({
  chainList,
  blockList,
});

export default reducer;
